Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows Tests #1553

Merged
merged 36 commits into from
Aug 2, 2023
Merged

Fix Windows Tests #1553

merged 36 commits into from
Aug 2, 2023

Conversation

varunagrawal
Copy link
Collaborator

My attempt at fixing #1541.

  1. Add fix for compilation in Visual Studio. This seems to be a weird issue with how size_t is interpreted since the multiple symbols defined error comes from additional declarations of std::map<Key, size_t>. This might be a bug in MSVC 16.
  2. Fixed some more tests across the repo.
  3. Updated the Windows CI to run additional GTSAM tests as well as some gtsam_unstable tests.

There is still quite a bit of work to do to get all the tests passing on Windows, but hopefully this is a good start point.

@varunagrawal varunagrawal self-assigned this Jun 21, 2023
@varunagrawal varunagrawal mentioned this pull request Jun 26, 2023
@talregev
Copy link
Contributor

talregev commented Jun 29, 2023

@varunagrawal You asked my help for these tests.
I can help you to compile them, but not run them (make the tests correct).
I found some bugs that I can share with you:
1. On this line: https://github.com/borglab/gtsam/blob/develop/gtsam_unstable/CMakeLists.txt#L111
It should be GTSAM_EXPORTS instead of GTSAM_UNSTABLE_EXPORTS. There isn't definition for GTSAM_UNSTABLE_EXPORTS. I think gtsam_unstable should import/export symbol as gtsam lib.
When I switch it, it make the dll import at compilation of gtsam_unstable. Need to investigate more deeply the bug.
2. On this line: https://github.com/borglab/gtsam/blob/develop/gtsam_unstable/CMakeLists.txt#L107
It should be GTSAM_IMPORT_STATIC instead GTSAM_UNSTABLE_IMPORT_STATIC. I didn't try it.
I think it also do import instead export and need to investigate more deeply the bug.

3. On this line https://github.com/borglab/gtsam/blob/develop/gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp#L46
It should add #include <numeric> for handle the compile error: error C2039: 'iota': is not a member of 'std'

Good luck to hunt more bugs!


Edit:
After check again, I think 1 and 2 are not bug, and need to look deeper to understand why it not find symbols.

@talregev
Copy link
Contributor

When compiling with ninja, it make the error more clear:

[24/311] Linking CXX executable bin\check_basis_program.exe
FAILED: bin/check_basis_program.exe
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=gtsam\basis\tests\CMakeFiles\check_basis_program.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testBasisFactors.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testChebyshev.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testChebyshev2.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testFourier.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testParameterMatrix.cpp.obj  /out:bin\check_basis_program.exe /implib:bin\check_basis_program.lib /pdb:bin\check_basis_program.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console  lib\CppUnitLiteDebug.lib  lib\gtsamDebug.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_serialization-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_system-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_filesystem-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_thread-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_atomic-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_date_time-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_regex-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_timer-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_chrono-vc140-mt-gd.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\tbb12_debug.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\tbbmalloc_debug.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\metis.lib  C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\GKlib.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D C:\src\gtsam\build\gtsam\basis\tests && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file C:/src/gtsam/gtsam/3rdparty/vcpkg/cache/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary C:/src/gtsam/build/bin/check_basis_program.exe -installedDir C:/src/gtsam/gtsam/3rdparty/vcpkg/cache/vcpkg/installed/x64-windows/debug/bin -OutVariable out""
LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testBasisFactors.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testChebyshev.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testChebyshev2.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testFourier.cpp.obj gtsam\basis\tests\CMakeFiles\check_basis_program.dir\testParameterMatrix.cpp.obj /out:bin\check_basis_program.exe /implib:bin\check_basis_program.lib /pdb:bin\check_basis_program.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console lib\CppUnitLiteDebug.lib lib\gtsamDebug.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_serialization-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_system-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_filesystem-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_thread-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_atomic-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_date_time-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_regex-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_timer-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\boost_chrono-vc140-mt-gd.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\tbb12_debug.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\tbbmalloc_debug.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\metis.lib C:\src\gtsam\gtsam\3rdparty\vcpkg\cache\vcpkg\installed\x64-windows\debug\lib\GKlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:gtsam\basis\tests\CMakeFiles\check_basis_program.dir/intermediate.manifest gtsam\basis\tests\CMakeFiles\check_basis_program.dir/manifest.res" failed (exit code 1120) with the following output:
   Creating library bin\check_basis_program.lib and object bin\check_basis_program.exp
testBasisFactors.cpp.obj : error LNK2019: unresolved external symbol "public: static class gtsam::Pose2 __cdecl gtsam::Pose2::ChartAtOrigin::Retract(class Eigen::Matrix<double,3,1,0,3,1> const &,class gtsam::OptionalJacobian<3,3>)" (?Retract@ChartAtOrigin@Pose2@gtsam@@SA?AV23@AEBV?$Matrix@N$02$00$0A@$02$00@Eigen@@V?$OptionalJacobian@$02$02@3@@Z) referenced in function "public: class gtsam::Pose2 __cdecl gtsam::Basis<class gtsam::Chebyshev2>::ManifoldEvaluationFunctor<class gtsam::Pose2>::apply(class gtsam::ParameterMatrix<3> const &,class gtsam::OptionalJacobian<-1,-1>)const " (?apply@?$ManifoldEvaluationFunctor@VPose2@gtsam@@@?$Basis@VChebyshev2@gtsam@@@gtsam@@QEBA?AVPose2@3@AEBV?$ParameterMatrix@$02@3@V?$OptionalJacobian@$0?0$0?0@3@@Z)
testChebyshev2.cpp.obj : error LNK2001: unresolved external symbol "public: static class gtsam::Pose2 __cdecl gtsam::Pose2::ChartAtOrigin::Retract(class Eigen::Matrix<double,3,1,0,3,1> const &,class gtsam::OptionalJacobian<3,3>)" (?Retract@ChartAtOrigin@Pose2@gtsam@@SA?AV23@AEBV?$Matrix@N$02$00$0A@$02$00@Eigen@@V?$OptionalJacobian@$02$02@3@@Z)
bin\check_basis_program.exe : fatal error LNK1120: 1 unresolved externals

@talregev
Copy link
Contributor

By the way, I am not sure if you notice. Even that the ci pass, some of the tests are not compile with missing symbols.

@talregev
Copy link
Contributor

testBasisFactors.cpp.obj : error LNK2019: unresolved external symbol "class Eigen::Matrix<double,-1,-1,0,-1,-1> __cdecl gtsam::kroneckerProductIdentity(unsigned __int64,class Eigen::Matrix<double,1,-1,1,1,-1> const &)" (?kroneckerProductIdentity@gtsam@@ya?AV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@_KAEBV?$Matrix@N$00$0?0$00$00$0?0@3@@z) referenced in function "protected: void __cdecl gtsam::Basis::VectorDerivativeFunctor::calculateJacobian(void)" (?calculateJacobian@VectorDerivativeFunctor@?$Basis@VChebyshev2@gtsam@@@gtsam@@IEAAXXZ)

This was referenced Jun 30, 2023
@varunagrawal
Copy link
Collaborator Author

  1. On this line: develop/gtsam_unstable/CMakeLists.txt#L111 It should be GTSAM_EXPORTS instead of GTSAM_UNSTABLE_EXPORTS. There isn't definition for GTSAM_UNSTABLE_EXPORTS. I think gtsam_unstable should import/export symbol as gtsam lib. When I switch it, it make the dll import at compilation of gtsam_unstable. Need to investigate more deeply the bug.

GTSAM_EXPORTS and GTSAM_UNSTABLE_EXPORTS are autogenerated as part of dllexport.h.in. So this is not a bug.

  1. On this line: develop/gtsam_unstable/CMakeLists.txt#L107 It should be GTSAM_IMPORT_STATIC instead GTSAM_UNSTABLE_IMPORT_STATIC. I didn't try it. I think it also do import instead export and need to investigate more deeply the bug.

Same reasoning as above. :)

  1. On this line develop/gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp#L46 It should add #include <numeric> for handle the compile error: error C2039: 'iota': is not a member of 'std'

Nice catch!

@varunagrawal
Copy link
Collaborator Author

varunagrawal commented Jun 30, 2023

By the way, I am not sure if you notice. Even that the ci pass, some of the tests are not compile with missing symbols.

Yup I am aware. That's the reason this PR is still a draft. :)

@talregev
Copy link
Contributor

talregev commented Jun 30, 2023

GTSAM_EXPORTS and GTSAM_UNSTABLE_EXPORTS are autogenerated as part of dllexport.h.in. So this is not a bug.

@varunagrawal Thank you the explanation. I was did a second review check, and I understand it my own that it ok. I edit my comment, and leave the original msg with strikes.

@varunagrawal varunagrawal mentioned this pull request Jun 30, 2023
@varunagrawal varunagrawal marked this pull request as ready for review August 1, 2023 14:36
@varunagrawal
Copy link
Collaborator Author

@talregev @mikesheffler @dellaert I fixed all the GTSAM tests for Windows. Only the tests for GTSAM_UNSTABLE are left which I will leave for later.

@talregev
Copy link
Contributor

talregev commented Aug 1, 2023

@varunagrawal Are you interesting to deal with these errors?
image

Copy link
Contributor

@talregev talregev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should squash the commits. It not recommended to have all these commits and merges to dev branch.

@varunagrawal
Copy link
Collaborator Author

You should squash the commits. It not recommended to have all these commits and merges to dev branch.

We prefer to keep the history so we can go back and identify bad commits and undo them. This is why we don't squash or force-push.

@varunagrawal
Copy link
Collaborator Author

@varunagrawal Are you interesting to deal with these errors? image

Why is it using gtsamDebug.dll in the Release config?

@varunagrawal
Copy link
Collaborator Author

@talregev can you please approve this PR so I can merge it? The CI should pass which is a good indicator that the fixes work.

@talregev
Copy link
Contributor

talregev commented Aug 1, 2023

@varunagrawal Are you interesting to deal with these errors? image

Why is it using gtsamDebug.dll in the Release config?

This is another bug you have in the cmake when I compile it with vcpkg.
I am not sure what happen in the regular compilation.

But the debug assertion still happen on your side. Are you interesting to solve it?

@varunagrawal
Copy link
Collaborator Author

This is another bug you have in the cmake when I compile it with vcpkg. I am not sure what happen in the regular compilation.

I have never had this issue. I have been compiling and debugging using the Release config for the last week and it seems to be fine. Maybe the issue is in your vcpkg settings?

But the debug assertion still happen on your side. Are you interesting to solve it?

I do not get this error on my end. I re-ran the tests again and they pass without problems.

@talregev
Copy link
Contributor

talregev commented Aug 1, 2023

I have never had this issue. I have been compiling and debugging using the Release config for the last week and it seems to be fine. Maybe the issue is in your vcpkg settings?

Let's deal with this later. It not for this PR.

I do not get this error on my end. I re-ran the tests again and they pass without problems.

Of course there isn't errors. It not enable. I can enable it and you will see these errors.

@varunagrawal
Copy link
Collaborator Author

varunagrawal commented Aug 1, 2023

Of course there isn't errors. It not enable. I can enable it and you will see these errors.

Sorry I don't understand. What is not enabled?

@talregev
Copy link
Contributor

talregev commented Aug 1, 2023

Sorry I don't understand. What is not enabled?

The flag that enable the debug assertion that enable extra checks on run time.

@varunagrawal
Copy link
Collaborator Author

Can you please share the changes here? I can run them locally.

@talregev
Copy link
Contributor

talregev commented Aug 1, 2023

I will. It will be later.

@varunagrawal
Copy link
Collaborator Author

I will. It will be later.

Then can you please approve this PR?

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! If this is ready to merge, go for it :-)

@varunagrawal varunagrawal merged commit e36590a into develop Aug 2, 2023
26 checks passed
@varunagrawal varunagrawal deleted the fix/windows-tests branch August 2, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants